package com.tcoiss.common.component.api.factory;

import com.tcoiss.common.component.api.RemoteLogService;
import com.tcoiss.common.component.api.model.OperLog;
import com.tcoiss.common.core.domain.R;
import com.tcoiss.common.component.api.model.ApiLogVo;
import com.tcoiss.common.component.api.model.SchemeLogVo;
import com.tcoiss.common.component.api.model.WorkLog;
import com.tcoiss.common.core.web.domain.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 日志服务降级处理
 * 
 * @author tcoiss
 */
@Component
public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);

    @Override
    public RemoteLogService create(Throwable throwable)
    {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new RemoteLogService()
        {
            @Override
            public R<Boolean> saveApiLog(ApiLogVo apiLog)
            {
                return null;
            }

            @Override
            public R<Boolean> saveSchemeLog(SchemeLogVo schemeLogVo) {
                return null;
            }

            @Override
            public SchemeLogVo queryWork(SchemeLogVo schemeLogVo) {
                return null;
            }

            @Override
            public R<Date> getSchemeLogNewTime(String executeNumber) {
                return null;
            }
            @Override
            public AjaxResult checkSchemeLog() {
                return null;
            }
            @Override
            public R<Boolean> saveWorkLog(WorkLog workExecuteLog) {
                return null;
            }

            @Override
            public R<Boolean> saveLog(OperLog sysOperLog) {
                return null;
            }

            @Override
            public R<Boolean> saveLogininfor(String username, String status, String message) {
                return null;
            }
        };

    }
}
